<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户</title>
    <link rel="stylesheet" type="text/css" href="../lib/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="../lib/themes/icon.css">
	<link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/4.7.0/css/font-awesome.css">
	<script type="text/javascript" src="../lib/jquery.min.js"></script>
	<script type="text/javascript" src="../lib/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="../lib/datagrid-filter.js"></script>
	<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
    <script src="https://cdn.staticfile.org/axios/0.18.0/axios.min.js"></script>
	<script type="text/javascript" src="../lib/tools.js"></script>
	<script type="text/javascript" src="../lib/mask/jquery.loadmask.min.js"></script>
	<script type="text/javascript" src="../lib/locale/easyui-lang-zh_CN.js"></script>
	<script type="text/javascript" src="../lib/base64.js"></script>
	<link href="../lib/mask/jquery.loadmask.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="../lib/mask/jquery.loadmask.min.js"></script>
</head>
<body>
    
    <table id="logsdatagrid"></table>
	<div id="logstab" style="padding: 10px;">
		<input id="dd1" class="easyui-datetimebox" label="开始时间:" labelPosition="left" style="width:25%;">
		<text>--</text>
		<input id="dd2" class="easyui-datetimebox" label="结束时间:" labelPosition="left" style="width:25%;">
		<a href="#" class="easyui-linkbutton" iconCls="icon-search" onclick="logs.search()">搜索</a>
	</div>
    <script>

		var logs={
			search:function(){
			var v1 = $('#dd1').datetimebox('getValue');
			var date1 = v1;	
			date1 = date1.substring(0,19);    
			date1 = date1.replace(/-/g,'/'); //必须把日期'-'转为'/'
			var timestamp1 = new Date(date1).getTime()/1000;	
		
		
			var v2 = $('#dd2').datetimebox('getValue');
			var date2 = v2;	
			date2 = date2.substring(0,19);    
			date2 = date2.replace(/-/g,'/'); //必须把日期'-'转为'/'
			var timestamp2 = new Date(date2).getTime()/1000;	 
			

			if(!v1 || !v2 || timestamp1>=timestamp2){
				$.messager.alert("提示","时间选择错误");
				return;
			}
			$("#logsdatagrid").datagrid("load",{
				starttime:timestamp1,
				endtime:timestamp2
			});

			$('#dd1').datetimebox('setValue',"");
			$('#dd2').datetimebox('setValue',"");

			}
		}


	var dg = $("#logsdatagrid").datagrid({
	    url:Network.geturl("/v1/listlog"),
		dataType:"json",
		pagination: true,
		rownumbers: true,
		pagination:true,  
		fit:true, 
		singleSelect:true,
		nowrap: true, 
		striped:true,
		fitColumns:true,
		striped:true,
		pageSize:15,
		pageList:[10,15,20,25,30,35],
		columns:[[
		{field:"handletime",title:"请求时间",width:'20%',align:'center',formatter:  
				function(value,row,index){  
					var timestamp = row.handletime+"";
					var d = new Date(timestamp * 1000);    //根据时间戳生成的时间对象
					var date = (d.getFullYear()) + "-" + 
							(d.getMonth() + 1) + "-" +
							(d.getDate()) + " " + 
							(d.getHours()) + ":" + 
							(d.getMinutes()) + ":" + 
							(d.getSeconds());
					return date;
				}
			},
			{field:'path',title:"请求路径",width:'30%',align:'center'},
			{field:'method',title:"请求方式",width:'15%',align:'center'},
            {field:"param",title:"请求参数",width:'45%',align:'center'},
            {field:"user",title:"用户",width:'10%',align:'center',},
			{field:"ipaddress",title:"请求地址",width:'10%',align:'center',}
			
			]],
			toolbar:"#logstab",
			onLoadError:function(msg){

		    },
		    onLoadSuccess:function(data){
				
		    } 
});
    </script>
</body>
</html>